import React, {
    Component
} from 'react';
import {
    Router,
    Route,
    Redirect,
    IndexRoute,
    browserHistory,
    hashHistory
} from 'react-router';

const history = process.env.NODE_ENV !== 'production' ? browserHistory : hashHistory;

//引入组件
const roots = (location, cb) => {
    require.ensure([], require => {
        cb(null, require('./Component/Common/roots').default)
    }, 'roots')
};
const demo = (location, cb) => {
    require.ensure([], require => {
        cb(null, require('./Component/demo').default)
    }, 'demo')
};
const login = (location, cb) => {
    require.ensure([], require => {
        cb(null, require('./Component/login').default)
    }, 'login')
};
const index = (location, cb) => {
    require.ensure([], require => {
        cb(null, require('./Component/index').default)
    }, 'index')
};
const test = (location, cb) => {
    require.ensure([], require => {
        cb(null, require('./Component/test').default)
    }, 'test')
};
const ueditor = (location, cb) => {
    require.ensure([], require => {
        cb(null, require('./Component/ueditor').default)
    }, 'ueditor')
};
const formadd = (location, cb) => {
    require.ensure([], require => {
        cb(null, require('./Component/formadd').default)
    }, 'formadd')
};

const banner = (location, cb) => {
    require.ensure([], require => {
        cb(null, require('./Component/banner').default)
    }, 'banner')
};

const schoolPartner = (location, cb) => {
    require.ensure([], require => {
        cb(null, require('./Component/schoolPartner').default)
    }, 'schoolPartner')
};

const news = (location, cb) => {
    require.ensure([], require => {
        cb(null, require('./Component/news').default)
    }, 'news')
};

const ecosphere = (location, cb) => {
    require.ensure([], require => {
        cb(null, require('./Component/ecosphere').default)
    }, 'ecosphere')
};

const cooperativePartner = (location, cb) => {
    require.ensure([], require => {
        cb(null, require('./Component/cooperativePartner').default)
    }, 'cooperativePartner')
};

const article = (location, cb) => {
    require.ensure([], require => {
        cb(null, require('./Component/article').default)
    }, 'article')
};

const about = (location, cb) => {
    require.ensure([], require => {
        cb(null, require('./Component/about').default)
    }, 'about')
};

const connect = (location, cb) => {
    require.ensure([], require => {
        cb(null, require('./Component/connect').default)
    }, 'connect')
};

const instruction = (location, cb) => {
    require.ensure([], require => {
        cb(null, require('./Component/instruction').default)
    }, 'instruction')
};


const RouteConfig = (
    <Router history={hashHistory}>
        <Route path='/' getComponent={login} />
        <Route path='/home' getComponent={roots}>
            <IndexRoute getComponent={index}/>
            <Route path='index' getComponent={index}/>
            <Route path='test' getComponent={test}/>
            <Route path='ueditor' getComponent={ueditor}/>
            <Route path='banner(/:from)' getComponent={banner}/>
            <Route path='schoolPartner(/:from)' getComponent={schoolPartner}/>
            <Route path='ecosphere(/:from)' getComponent={ecosphere}/>
            <Route path='cooperativePartner(/:from)' getComponent={cooperativePartner}/>
            <Route path='news(/:from)' getComponent={news}/>
            <Route path='article(/:type)(/:id)' getComponent={article}/>
            <Route path='about(/:from)' getComponent={about}/>
            <Route path='connect(/:from)' getComponent={connect}/>
            <Route path='instruction' getComponent={instruction}/>
            <Route path='*' getComponent={demo}/>
        </Route>
    </Router>
)
export default RouteConfig;
